package com.hotel.tv.application.user.services.auth.impl;

import com.autumn.zero.authorization.application.services.auth.impl.AbstractAuthAppServiceBase;
import com.autumn.zero.authorization.application.services.callback.AuthCallback;
import com.autumn.zero.authorization.application.services.captcha.ImageCaptchaAppService;
import com.autumn.zero.authorization.values.ResourcesModuleTreeValue;
import com.hotel.tv.application.user.dto.auth.UserClientLoginInfoOutput;
import com.hotel.tv.application.user.services.auth.AuthAppService;
import com.hotel.tv.entities.auth.HotelRole;
import com.hotel.tv.entities.auth.HotelUser;
import com.hotel.tv.constants.HotelUserTypeConstant;
import com.hotel.tv.runtime.session.HotelUserSession;
import com.hotel.tv.services.HotelAuthorizationService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-04-10 11:21
 **/
@Service
@Primary
public class AuthAppServiceImpl
        extends AbstractAuthAppServiceBase<HotelUser, HotelRole, UserClientLoginInfoOutput>
        implements AuthAppService {

    /**
     * @param authService
     * @param authCallback
     * @param captchaAppService
     */
    public AuthAppServiceImpl(HotelAuthorizationService authService,
                              AuthCallback authCallback,
                              ImageCaptchaAppService captchaAppService) {
        super(authService, authCallback, captchaAppService);
    }

    @Override
    protected UserClientLoginInfoOutput createUserLoginInfo() {
        UserClientLoginInfoOutput infoOutput = new UserClientLoginInfoOutput();
        HotelUserSession userSession = (HotelUserSession) this.getSession();
        infoOutput.setVip(userSession.isVip());
        return infoOutput;
    }

    @Override
    public HotelUser createRegisterUser() {
        HotelUser user = new HotelUser();
        user.setUserType(HotelUserTypeConstant.USER);
        return user;
    }

    @Override
    public List<ResourcesModuleTreeValue> queryUserMenuTree() {
        return new ArrayList<>();
    }

    @Override
    public String getModuleName() {
        return "用户授权";
    }
}
